<?php
declare (strict_types = 1);

namespace app\movie\controller;

use think\facade\Db;

class Index
{
    public function index()
    {
        return '您好！这是一个[movie]示例应用';
    }

    public function page(\think\Request $request): \think\response\Json
    {
        $param = $request->param();
        $pageNo = 1;
        $pageSize = 10;
        if(isset($param['pageNo'])){
            $pageNo = $param['pageNo'];
        }
        if(isset($param['keyWord'])){
            $where[] = ['name', 'like', '%'.$param['keyWord'].'%'];
        }
        $where[] = ['id', '>', 0];
        $arr = Db::table('movie_video')
            ->where($where)
            ->paginate([
                'list_rows'=> $pageSize,
                'page' => $pageNo,
            ]);
        return json([
            'code'=> 200,
            'data' => $arr,
            'message' => '操作成功'
        ]);
    }
}
